home *** CD-ROM | disk | FTP | other *** search
/ Interactive Media Design Review 1999 / Interactive Media Design Review 1999.iso / pc / Demos / Herois / Codigo.Cst / 00191_MM Jonny- estrelas.ls < prev    next >
Encoding:
Text File  |  1999-03-19  |  1.8 KB  |  68 lines

  1. property spr, mem
  2. property y_max, y_min, x_max, x_min
  3. property espera -- Tempo de espera entre cada mudanca (em ticks) 
  4. property ultimaTroca
  5.  
  6. on getBehaviorDescription
  7.   return "Anima sprites"
  8. end
  9.  
  10. on getPropertyDescriptionList
  11.   set p_list = [ ┬¼
  12.     #x_min: [ #comment:   "X minimo", ┬¼
  13.                     #format:   #integer, ┬¼
  14.                    #default:   0 ], ┬¼
  15.     #y_min: [ #comment:   "Y minimo ", ┬¼
  16.                     #format:   #integer, ┬¼
  17.                    #default:   0 ], ┬¼
  18.     #x_max: [ #comment:   "X maximo", ┬¼
  19.                     #format:   #integer, ┬¼
  20.                    #default:   639 ], ┬¼
  21.     #y_max: [ #comment:   "Y maximo ", ┬¼
  22.                     #format:   #integer, ┬¼
  23.                    #default:   479 ], ┬¼
  24.     #espera: [ #comment: "Espera entre cada troca em 1/60s (velocidade)",┬¼
  25.                      #format: #integer,┬¼
  26.                      #default: 180 ]┬¼
  27.   ]
  28.   return p_list
  29. end
  30.  
  31. on beginSprite me
  32.   set spr = the spriteNum of me
  33.   set mem = the member of sprite spr
  34.   
  35.   set w = the width of sprite spr
  36.   set h = the height of sprite spr
  37.   set x = the locH of the regPoint of member mem
  38.   set y = the locV of the regPoint of member mem
  39.   set x_min = x_min + x
  40.   set y_min = y_min + y
  41.   set x_max = x_max - (w - x)
  42.   set y_max = y_max - (h - y)
  43.   
  44.   puppetSprite spr, true
  45.   posiciona me
  46. end
  47.  
  48. on cleanSprite me
  49.   puppetSprite spr, false
  50. end 
  51.  
  52. on posiciona me
  53.   set x = random(x_max - x_min + 1) - 1 + x_min
  54.   set y = random(y_max - y_min + 1) - 1 + y_min
  55.   set the locH of sprite spr to x
  56.   set the locV of sprite spr to y
  57.   set ultimaTroca = the timer
  58. end
  59.  
  60. on idleSprite me
  61.   global gMustUpdate
  62.   
  63.   -- Testa se ja e' hora de trocar figura
  64.   if (the timer - ultimaTroca) > espera then
  65.     posiciona me
  66.     set gMustUpdate = true
  67.   end if
  68. end